<?php

// If this file is called directly, busted!
if( !defined( 'ABSPATH' ) ) {
    exit;
}
/*----------------------------------------------------------------------------------------------------------
    Single Posts Template - we use PHP comments instead of HTML, to reduce the page size.
-----------------------------------------------------------------------------------------------------------*/
get_header(); ?>

<?php if ( defined( 'MYARCADE_VERSION' ) and is_game() ) : ?>

<?php // game variables
$custom_meta 				= get_post_custom( $post->ID );
$td_progressbar_enabled 	= gameleon_get_option( 'td_enable_progress_bar' );
$td_arcade_thumbnail_size 	= gameleon_get_option( 'td_arcade_featured_img' );
$td_fullscreen_enabled 		= gameleon_get_option( 'td_fullscreen_enabled' );
$td_lightsoff_enabled 		= gameleon_get_option( 'td_lightsoff_enabled' );
$td_screens_tab_enabled 	= gameleon_get_option( 'td_screenshoots_tab' ); // game screenshots
$td_video_tab_enabled 		= gameleon_get_option( 'td_video_tab' ); // game video
$td_cutom_tab_enabled 		= gameleon_get_option( 'td_custom_tab' );
$td_tab_play_text 			= gameleon_get_option( 'td_tab_play_text' );
$td_tab_screen_text 		= gameleon_get_option( 'td_tab_screen_text' );
$td_tab_video_text 			= gameleon_get_option( 'td_tab_video_text' );
$td_custom_text  			= gameleon_get_option( 'td_custom_text' );
$td_custom_tab 				= gameleon_get_option( 'td_custom_tab_content' );
$instructions 				= $custom_meta['mabp_instructions'][0];
$thumb_url 					= myarcade_get_thumbnail_url();
?>

<?php if ( function_exists( 'myarcade_count_screenshots' ) ) : ?>
<?php $screenshots = myarcade_count_screenshots(); ?>
<?php else: ?>
<?php $screenshots = ''; ?>
<?php endif; ?>

<?php if ( function_exists( 'myarcade_video' ) ) : ?>
<?php $video_url = myarcade_video(); ?>
<?php else: ?>
<?php $video_url = ''; ?>
<?php endif; ?>


<div id="content-arcade" class="grid col-1060">
<div class="td-content-inner-single-arcade">

<div id="full-screen-wrapp">


<div class="widget-title">
<h1><?php myarcade_title(); ?></h1>

<div class="td-game-buttons">
<?php if ( $td_fullscreen_enabled ) : ?>
<div class="td-fullscreen">
	<?php _e( 'Fullscreen', 'gameleon' ); ?>
</div>
<?php endif; ?>

<?php if ( $td_lightsoff_enabled ) : ?>
<div class="td-switch">
	<?php _e( 'Light Switch', 'gameleon' ); ?>
</div>
<?php endif; ?>

</div>

</div>

<div class="td-wrap-content-arcade">

<div class="clearfix"></div>


<?php if ( $td_progressbar_enabled ) : ?>
<?php get_template_part('/includes/progressbar'); ?>

<div class="td_before-game-loading">
<div id="showprogressbar">

<?php echo responsive_interstitial_ad(); // show interstitial ad ?>

<div id="progressbar">
<span id="progresstext">0%</span>
<div id="progressbarloadbg">&thinsp;</div>
</div>


</div><?php // end of #showprogressbar/ ?>
</div><?php // end of .td_before-game-loading / ?>

<div id="progressbarloadtext" onclick="window.hide();">
<?php echo gameleon_get_option( 'td_progressbar_text' ); ?>
</div>

<?php endif; // end of check "$td_progressbar_enabled" ?>

<div class="clearfix"></div>

<div id="td-game-wrap" class="showfitvids">

<div class="td-embed-container">

<?php
if ( function_exists( 'get_game' ) ) { // yep... show the MyArcade  game code
	 /* mypostid global is needed for MyScoresPresenter */
	global $mypostid;
	$mypostid = $post->ID;
	echo myarcade_get_leaderboard_code();
	echo get_game( $post->ID );
}
?>

</div><?php // end of embed-container / ?>
</div><?php // end of #td-game-wrap / ?>

</div><?php // end of .td-wrap-content-arcade / ?>
</div><?php // end of #full-screen-wrapp / ?>

<div class="td-game-ad-space">
<?php echo responsive_ad_bellow_the_game(); // show the below the game ad ?>
</div><?php // end of .td-game-ad-space / ?>

<?php if( gameleon_get_option( 'td_post_navigation' ) == 1 ) : ?>
<div class="navigation">
<div class="previous"><?php previous_post_link( ' &#xf053;  &nbsp;  %link' ); ?></div>
<div class="next"><?php next_post_link( '%link &nbsp; &#xf054;' ); ?></div>
</div><?php // end of .navigation / ?>
<?php endif ; // end if( gameleon_get_option( 'td_post_navigation' ) ?>

</div><?php // end of .td-content-inner-single-arcade / ?>
</div><?php // end of #content-arcade / ?>


<div id="td-game-tabs" class="grid col-1060">
<div class="td-content-inner-single-arcade">
<div id="gametabs">

<ul class="tab-links">
<li class="active"><a href="#tab1"><?php echo esc_html( $td_tab_play_text ); ?></a></li>

<?php if ( defined( 'MYARCADE_VERSION' ) and is_game() and $td_screens_tab_enabled and ( $screenshots ) ) : ?>
<li class="td-tab-2"><a href="#tab2"><?php echo esc_html( $td_tab_screen_text ); ?></a></li>
<?php endif; ?>


<?php if ( defined( 'MYARCADE_VERSION' ) and is_game() and $td_video_tab_enabled and $video_url ): ?>
<li class="td-tab-3"><a href="#tab3"><?php echo esc_html( $td_tab_video_text ); ?></a></li>
<?php endif; ?>


<?php if ( $td_cutom_tab_enabled ) : ?>
<li><a href="#tab4"><?php echo esc_html( $td_custom_text ); ?></a></li>
<?php endif; ?>

</ul>

<div class="gametab-content">

<div id="tab1" class="tab active">
<?php echo do_shortcode( $instructions ); ?>
</div>

<?php if ( defined( 'MYARCADE_VERSION' ) and is_game() and $td_screens_tab_enabled and ( $screenshots ) ) : ?>
<div id="tab2" class="tab td-screens-popup">
<?php myarcade_all_screenshots( 224, 224, 'td-game-screens-class'); ?>
</div>
<?php endif; ?>


<?php if ( defined( 'MYARCADE_VERSION' ) and is_game() and $td_video_tab_enabled and $video_url ): ?>
<div id="tab3" class="tab">
<div class="myarcade-video">
<?php echo myarcade_video( 1018, 573 ); ?>
</div>
</div>
<?php endif; ?>


<?php if ( $td_cutom_tab_enabled ) : ?>
<div id="tab4" class="tab">
<?php if( gameleon_get_option( 'td_custom_tab_content' ) ) :
echo do_shortcode( stripslashes( $td_custom_tab ));
endif; ?>
</div>
<?php endif; ?>


</div><?php // end of .tab-content / ?>
</div><?php // end of #gametabs / ?>
</div><?php // end of .td-content-inner-single-arcade / ?>
</div><?php // end of .col-1060 / ?>


<?php endif; // end of check "MYARCADE_VERSION" ?>



<?php // ---------------------------------- GAME OVER ---------------------------------- / ?>

<div id="content" class="grid col-700">

<div class="td-content-inner-single">
<div class="widget-title">

<?php if ( defined( 'MYARCADE_VERSION' ) and is_game() ) : ?>

<h3><?php _e( 'Game Details', 'gameleon' ); ?></h3>

<?php else: ?>

<?php the_title( '<h1>', '</h1>' ); ?>

<?php endif; // end of check "MYARCADE_VERSION" ?>


</div>


<div class="td-wrap-content">

<?php get_gameleon_breadcrumb_lists(); ?>


<?php if( have_posts() ) : ?>
<?php while( have_posts() ) : the_post(); ?>


<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php
$td_show_post_meta = gameleon_get_option( 'td_post_meta_single' );
if ( $td_show_post_meta ) : ?>
<?php get_template_part( 'post-single-meta' ); ?>
<?php endif; ?>

<div class="post-entry">

<?php if ( defined( 'MYARCADE_VERSION' ) and is_game() ) : ?>
<a href="<?php echo $thumb_url; ?>" title="<?php myarcade_title(); ?>">
<?php myarcade_thumbnail( $td_arcade_thumbnail_size, $td_arcade_thumbnail_size, 'alignleft arcade-width' ); ?>
</a>
<?php else: ?>
<?php gameleon_featured_image(); ?>
<?php endif; ?>

<?php the_content( __( 'Read More...', 'gameleon' ) ); ?>

<?php get_template_part( 'post-data' ); ?>

<?php if( gameleon_get_option( 'td_post_navigation' ) == 1 and defined( 'MYARCADE_VERSION' ) and !is_game() ) : ?>

<div class="navigation">
<div class="previous"><?php previous_post_link( ' &#xf053;  &nbsp;  %link' ); ?></div>
<div class="next"><?php next_post_link( '%link &nbsp; &#xf054;' ); ?></div>
</div><?php // end of .navigation / ?>

<?php endif ; // end if( gameleon_get_option( 'td_post_navigation' ) ?>

<?php wp_link_pages( array( 'before' => '<div class="pagination">' . __( 'Pages:', 'gameleon' ), 'after' => '</div>' ) ); ?>

<div class="clearfix"></div>

</div><?php // end of .post-entry / ?>
</div><?php // end of #post-the_ID(); / ?>

</div><?php // end of td-wrap-content / ?>
</div><?php // end of td-content-inner / ?>



<?php  if( !function_exists( 'wpsabox_author_box' ) and get_the_author_meta( 'description' ) != '' and gameleon_get_option( 'td_post_author_box' ) == 1 ) : ?>

<div class="td-content-inner-single">

<div id="author-meta">
<?php if( function_exists( 'get_avatar' ) ) {
echo get_avatar( get_the_author_meta( 'user_email' ), '100' );
} ?>
<div class="about-author"><?php the_author_posts_link(); ?></div>
<div class="auth-desc vcard author"><span class="fn"><?php the_author_meta( 'description' ) ?></span></div>
<div class="clearfix"></div>
</div><?php // end of #author-meta / ?>

</div><?php // end of td-content-inner-single / ?>

<?php endif; // no description, no author's meta ?>


<?php if ( function_exists( 'wpsabox_author_box' ) ) :?>
<div class="td-content-inner-single-sabox">
<?php echo wpsabox_author_box(); // Our Simple Author Box plugin ?>
</div><?php // end of td-content-inner-single-sabox / ?>
<?php endif; ?>


<?php echo gameleon_related_posts(); ?>

<?php comments_template( '', true ); ?>

<?php endwhile; endif; ?>

<?php get_template_part( 'loop-nav' ); // pagination ?>


</div><?php // end of #content / ?>


<?php get_sidebar(); ?>
<?php get_footer(); ?>